package com.zr.d_c.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.zr.d_c.service.AdminService;
import com.zr.d_c.serviceimpl.AdminServiceImpl;

import net.sf.json.JSONObject;
/**
 * 管理员管理顾客信息的功能(重置密码)
 * @author Administrator
 *
 */
public class ManagerCustomerToResetUpswController extends HttpServlet{
	AdminService adminservice = new AdminServiceImpl();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		HttpSession session = req.getSession();
		PrintWriter pw = resp.getWriter();
		JSONObject customer =new JSONObject();
		int page = Integer.parseInt(req.getParameter("page"));
		int pageSize = Integer.parseInt(req.getParameter("rows"));
		int start = (page-1)*pageSize;
		String searchcustomer = req.getParameter("searchcname");
		if(searchcustomer!=null){
			customer = adminservice.getCustomerToResetUpsw(start, pageSize, searchcustomer);
		}else{
			customer = adminservice.getAllCustomerToResetUpsw(start, pageSize);
		}
		pw.write(customer.toString());
		pw.close();
	}
}
